package com.wuye.model.repair;

import net.sf.json.JSONObject;

/**
 * Created by jiawenlong on 2016/7/26.
 */
public enum RepairState {

    unconfirmed(0, "已申请"), confirmed(1, "已接单"),
    cancelled(2, "已取消"),
    financialConfirmation(3, "已完成");

    RepairState(int orderState, String stateDesc) {
        this.state = orderState;
        this.stateDesc = stateDesc;
    }

    //状态值
    final public int state;
    //订单描述
    final public String stateDesc;
    //此状态可退款

    public int getState() {
        return state;
    }

    public String getStateDesc() {
        return stateDesc;
    }

    public static RepairState find(int state) {
        for (RepairState os : RepairState.values())
            if (state == os.state)
                return os;
        return null;
    }


    public static JSONObject toJson() {
        JSONObject object = new JSONObject();
        for (RepairState os : RepairState.values()) {
            object.put(os.state, os.stateDesc);
        }
        return object;
    }
}
